﻿using Prism.Events;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZoneLinePacking.Core.EventArgs {

    /// <summary>
    /// 通用形发布订阅消息事件参数类
    /// </summary>
    public class PubSubEventArgs : PubSubEvent<MessageData> {
       
    }

    public class MessageData {
        public MessageData() { }
        public MessageData(string Code, IDialogParameters Parameters) {
            this.Code = Code;
            this.Parameters = Parameters;
        }

        /// <summary>
        /// 标志
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 参数
        /// </summary>
        public IDialogParameters Parameters { get; set; } = new DialogParameters();


        /// <summary>
        /// 获取参数值
        /// </summary>
        public T GetParameterValue<T>(string key) {
            if (Parameters == null || !Parameters.ContainsKey(key))
                return default;
            return Parameters.GetValue<T>(key);
        }

        /// <summary>
        /// 是否包括Key
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool ContainsParameterKey(string key) {
            return Parameters.ContainsKey(key);
        }
    }

}
